import request from '../utils/request';
import { API_PATHS } from '../constants/api';

// 订单列表查询参数
export interface OrderListParams {
  current?: number;
  size?: number;
  orderNo?: string;
  status?: string;
  productName?: string;
  [key: string]: any;
}

// 订单信息接口
export interface OrderInfo {
  id: string;
  orderNo: string;
  productId: string;
  productName: string;
  productType: string;
  amount: number;
  status: string;
  payStatus: string;
  payTime: string;
  buyer: string;
  seller: string;
  createdAt: string;
  updatedAt: string;
}

// 订单详情接口
export interface OrderDetail extends OrderInfo {
  productDetail: {
    id: string;
    name: string;
    description: string;
    price: number;
  };
  paymentInfo: {
    paymentMethod: string;
    transactionId: string;
    paymentTime: string;
    paymentAmount: number;
  };
  attachments: Array<{
    name: string;
    url: string;
  }>;
}

// 分页响应接口
export interface PaginationResponse<T> {
  records: T[];
  total: number;
  size: number;
  current: number;
}

// 获取订单列表
export async function getOrderList(params: OrderListParams): Promise<PaginationResponse<OrderInfo>> {
  const response = await request.post(API_PATHS.ORDER.LIST, params);
  return response.data;
}

// 获取订单详情
export async function getOrderDetail(orderId: string): Promise<OrderDetail> {
  const response = await request.get(API_PATHS.ORDER.DETAIL(orderId));
  return response.data;
} 